package api

/**
 * @Description
 * @Author huran
 * @Date
 * @Param
 * @return
 **/
import (
	"github.com/gin-gonic/gin"
	"github.com/mojocn/base64Captcha"
	"go.uber.org/zap"
	"net/http"
)

// 验证码
var store = base64Captcha.DefaultMemStore

func GetCaptcha(ctx *gin.Context) {
	digit := base64Captcha.NewDriverDigit(240, 80, 5, 0.7, 80)
	cp := base64Captcha.NewCaptcha(digit, store)
	id, s, _, err := cp.Generate()
	if err != nil {
		zap.S().Error("生成验证码错误:", err.Error())
		ctx.JSON(http.StatusInternalServerError, gin.H{
			"msg": "生成验证码错误",
		})
		return
	}
	ctx.JSON(http.StatusOK, gin.H{
		"captchaId": id,
		"picPath":   s,
	})
}
func Health(ctx *gin.Context) {
	ctx.JSON(http.StatusOK, gin.H{})
	return
}
